package LeetCode;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

import static java.lang.Math.abs;

/**
 * @Author Kechelle
 * @Date 2020/9/27 16:06
 * @Version 1.0
 */
public class Code1534 {
    public static int countGoodTriplets(int[] arr, int a, int b, int c) {
        int n = arr.length;
        int count = 0;
        for (int i=0;i<n;i++){
            for (int j=i+1;j<n;j++){
                for (int k=j+1;k<n;k++){
                    if (abs(arr[i]-arr[j])<=a&&abs(arr[j]-arr[k])<=b&&abs(arr[i]-arr[k])<=c){
                        count++;
                    }
                }
            }
        }
        return count;
    }
    public static void main(String[] args) {
        int[] nums = {3,0,1,1,9,7};
        System.out.println(countGoodTriplets(nums,7,2,3));
    }
}
